﻿@model List<IdentityServer4.EntityFramework.Entities.Client>
@using IdentityServer4.EntityFramework.Mappers

@{
    ViewData["Title"] = "Clients";
}
<link href="~/css/showtip.css" rel="stylesheet" />
<style>
    table {
        table-layout: fixed;
        word-break: break-all;
    }

    hr {
        margin: 6px;
    }

    .alert-auth {
        margin: 15px 0 -10px 0;
        color: #ff5567;
        font-size: 14px;
    }
</style>
<div>
    <h2>@ViewData["Title"]</h2>
</div>
<hr />

<div class="row">
    <div class="col-md-12">
        <div>
            <div class="pull-left">
                <a asp-action="CreateOrEdit" asp-route-id="0" class="btn btn-primary">
                    <span title="Create New" class="glyphicon glyphicon-plus-sign"></span> Add New
                </a>
                <p class="alert-auth">如果你需要一个客户端，用来学习三端联调，但是又不想自己搭认证中心，可以使用本平台，请联系老张的哲学。</p>
            </div>
        </div>
    </div>
</div>
<br />
<div class="">
    <table class="table table-striped">
        <thead>
            <tr>
                <th style="width:150px;">客户端Id</th>
                <th style="width:230px;">客户端名</th>
                <th style="width:180px;">授权类型</th>
                <th style="width:210px;">作用域</th>
                <th>允许跨域</th>
                <th>回调地址</th>
                <th>退出回调</th>
                <th style="width:100px;">Operate</th>
            </tr>
        </thead>
        <tbody>
            @foreach (var item in Model)
            {
                var clientModel = item.ToModel();
                <tr>
                    <td>
                        @(!string.IsNullOrEmpty(item.ClientId) && item.ClientId.Contains("xyz000!") ? "VIP用户专属" : item.ClientId)
                    </td>
                    <td>
                        @Html.DisplayFor(modelItem => item.ClientName)
                    </td>
                    <td>
                        @Html.Raw(string.Join("<br>", clientModel.AllowedGrantTypes))
                    </td>
                    <td>
                        @Html.Raw(string.Join("<br>", clientModel.AllowedScopes))
                    </td>
                    <td>
                        @Html.Raw(string.Join("<hr>", clientModel.AllowedCorsOrigins))
                    </td>
                    <td>
                        @Html.Raw(string.Join("<hr>", clientModel.RedirectUris))
                    </td>
                    <td>
                        @Html.Raw(string.Join("<hr>", clientModel.PostLogoutRedirectUris))
                    </td>
                    <td>
                        <a asp-action="CreateOrEdit" asp-route-id="@item.Id" title="Edit" class="btn btn-warning">
                            <span class="glyphicon glyphicon-pencil">Edit</span>
                        </a>

                    </td>
                </tr>
            }
        </tbody>
    </table>
</div>

